<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>案例3</title>
</head>

<body>
    <div style="width: 50px;margin: 0 auto;">
        <input type="button" id="btn" onclick="add()" value="0">
    </div>

    <script>
        let a = 0
        let btn = document.querySelector('#btn')

        function add() {
            a++
            btn.value = a
        }
    </script>
</body>

</html>